#include "MembershipHistory.h"

#include "Helpers.h"

MembershipHistory& MembershipHistory::operator=( const MembershipHistory& other )
{
  if (this == &other)
    return *this;
  m_id = other.m_id;
  m_memberId = other.m_memberId;
  m_committeeId = other.m_committeeId;
  m_entryDate = other.m_entryDate;
  m_exitDate = other.m_exitDate;
  return *this;
}

bool MembershipHistory::operator==( const MembershipHistory& other ) const
{
  return m_id == other.m_id &&
    m_memberId == other.m_memberId &&
    m_committeeId == other.m_committeeId &&
    m_entryDate == other.m_entryDate &&
    m_exitDate == other.m_exitDate;
}

std::ostream& operator<<( std::ostream& stream, const MembershipHistory &history )
{
  return stream << 
    history.id() << c_delm <<
    history.memberId() << c_delm <<
    history.committeeId() << c_delm <<
    history.entryDate() << c_delm <<
    history.exitDate() << std::endl;
}

std::istream& operator>>( std::istream& stream, MembershipHistory& committee )
{
  CsvRow row;
  stream >> row;
  if (row.empty())
    return stream;
  committee = MembershipHistory(row[0], row[1], row[2], as<time_t>(row[3]), as<time_t>(row[4]));
  return stream;
}
